package fun.xinnix.controller;

import fun.xinnix.entity.Result;
import fun.xinnix.entity.dto.KafkaMessageDto;
import fun.xinnix.service.KafkaService;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/kafka")
public class KafkaController {
    @Resource
    KafkaService kafkaService;

    @PostMapping("/send")
    public Result send(@RequestBody @Valid KafkaMessageDto dto) {
        kafkaService.sendMessage(dto);
        return Result.success();
    }
}
